package com.yy.controller;

import com.yy.mapper.MeetMapper;
import com.yy.pojo.Dpt;
import com.yy.pojo.File;
import com.yy.pojo.Meet;
import com.yy.service.MeetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: yy
 * @Date
 */
@RestController
@Controller
@RequestMapping("/meet")
public class MeetController {
    @Autowired
     MeetService meetService;


    /**
     * 添加一个会议
     */
    @PostMapping("/addMeet")
    public int addMeet(@RequestBody Meet meet){
        return meetService.addMeet(meet);
    }




//    @GetMapping  ("/addMeet1")
//    public String addMeet(){
//        Meet meet = new Meet("ewf","","fef","ger","greg","greg","hth","htrh");
//        meetService.addMeet(meet);
//        return "ok";
//    }



    /**
     * 查看会议
     */
    @GetMapping("/getMeetList")
    public List<Meet> getMeetList(){
        List<Meet> meetList = meetService.getMeetList();
        for (Meet meet : meetList){
            System.out.println(meet);
        }
        return meetList;
    }


//    @GetMapping("/getFileList")
//    public List<File> getFileList(){
//        List<File> fileList = fileService.getFileList();
//        for (File file : fileList){
//            System.out.println(file);
//        }
//        return fileList;
//    }

    @DeleteMapping("/deleteMeet/{mId}")
    public int deleteMeet(@PathVariable("mId") String mId){
        return meetService.deleteMeet(mId);
    }



    @GetMapping("/findBymId/{mId}")
    public Meet findBymId(@PathVariable ("mId") String mId){
        return meetService.findBymId(mId);

    }


    @PutMapping("/update")
    public String update(@RequestBody Meet meet){
        int result=meetService.addMeet(meet);
        if (result!=0){
            return "success";
        }else {
            return "error";
        }

    }

}
